package com.example.alphabetindexer.util;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.view.WindowManager;

public class UIHelp {

	private static ProgressDialog progressDialog;

	public static void showLoading(Context context) {
		showLoading(context, "数据加载中...");
	}

	public static void showLoading(Context context, String message) {
		// 隐藏键盘
		((Activity) context).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

		progressDialog = new ProgressDialog(context);
		progressDialog.setMessage(message);
		progressDialog.setIndeterminate(true);
		progressDialog.setCancelable(true);
		progressDialog.show();
	}

	public static void closeLoading() {
		if (progressDialog != null) {
			progressDialog.dismiss();
			progressDialog = null;
		}
	}
}
